home *** CD-ROM | disk | FTP | other *** search
/ Network CD 2 / Network CD - Volume 2.iso / twinopus / dopus / twinhandler.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1995-02-27  |  4.2 KB  |  132 lines

  1. /*
  2.  *
  3.  *  Handler to deal with double-clicks in DOpus for TwinExpress.
  4.  *
  5.  * (c) 1994 by K.P. van Beem (2:280/464.2, patrick.van.beem@aobh.xs4all.nl)
  6.  *
  7.  * Based on the DOpusLhaARexx package by Geoff Seeley (but you can better
  8.  * use GuiArc in stead of DOpus and a script, to deal with archives)
  9.  *
  10.  * - Supports Drag / Dbl Click to copy or Enter Dirs
  11.  *    - Known Bug, First Dbl Click does a Enter Dir (Request not work ??)
  12.  *                 The Program then works properly from then on ... !!
  13.  *
  14.  * - Added Directory caching...
  15.  *    - when this is called (on startup), makes a dir in temp for storage of directories
  16.  */
  17.  
  18. /* make the caching Dir*/
  19. /* address COMMAND "MakeDir >NIL: T:TwinDirs" */
  20.  
  21. DOpusPort = 'DOPUS.1'
  22. TwinPort  = 'TWIN.1'
  23.  
  24. if ~show(l,"rexxsupport.library") then
  25.     call addlib("rexxsupport.library",0,-30,0)
  26. if showlist('Ports', TwinPort) then do
  27.    call ExitIt
  28. end
  29.  
  30. options results
  31.  
  32. /* open our message port */
  33. OurPort = openport(TwinPort)
  34. HandlerStatus = 'OPEN'
  35.  
  36. do until HandlerStatus = 'CLOSE'
  37.    call waitpkt(TwinPort)
  38.    Packet = getpkt(TwinPort)
  39.    if Packet ~= null() then do
  40.       Cmd = getarg(Packet, 0)
  41.       Directory = getarg(Packet, 2) /* entry text   */
  42.  
  43.       call reply(Packet, 0)
  44.  
  45.       /*respond to a Double-Click*/
  46.       if Cmd = '1' then do
  47.          address value DOpusPort
  48.          /* Get current directory */
  49.          'Status 6 -1'
  50.          GetEntry Result
  51.          FilePath = Result
  52.          if left(FilePath,1) ~= '*' then
  53.             TopText "You are not in a Twin directory !!"
  54.          else do
  55.             FilePath = SubStr(FilePath,2)
  56.             /* Create new path and... */
  57.             if right(FilePath,1) = ':' then
  58.                FilePath = FilePath || Strip(left(Directory,25))
  59.             else
  60.                FilePath = FilePath || '/' || Strip(left(Directory,25))
  61.             /* Check if entry is a directory */
  62.  
  63.             if words(FilePath) > 1 then
  64.                Request "Spaces in a File / Directory Name are not Allowed !!"
  65.             else
  66.                if SubStr(Directory,26,9) ~= "Directory" then
  67.                   /*routine to type files...*/
  68.                   address COMMAND "rx Rexx:DOpus/TypeFile.rexx" FilePath
  69.                else do
  70.                   /* ...command the actually entering of the directory */
  71.                   address COMMAND "rx Rexx:DOpus/ReadDir.rexx" FilePath
  72.                end
  73.          end
  74.       end
  75.  
  76.       /*respond to a Click-m-Click*/
  77.       if Cmd = '2' then do
  78.          /* Check if entry is a directory */
  79.          if SubStr(Directory,26,9) = "Directory" then do
  80.             /* copy or Enter ? */
  81.             Request "List Dir there [Okay]  or  Copy Dir there [Cancel] "
  82.  
  83.             if Result = 1 then do
  84.  
  85.                address value DOpusPort
  86.                /* Get current directory */
  87.                OtherWindow
  88.                'Status 6 -1'
  89.                GetEntry Result
  90.                FilePath = Result
  91.                if left(FilePath,1) ~= '*' then
  92.                   TopText "You are not in a Twin directory !!"
  93.                else do
  94.                   FilePath = SubStr(FilePath,2)
  95.                   /* Create new path and... */
  96.                   if right(FilePath,1) = ':' then
  97.                      FilePath = FilePath || Strip(left(Directory,25))
  98.                   else
  99.                      FilePath = FilePath || '/' || Strip(left(Directory,25))
  100.  
  101.                   if words(FilePath) > 1 then
  102.                      Request "Spaces in a File / Directory Name are not Allowed !!"
  103.                   else do
  104.                      OtherWindow
  105.                      address COMMAND "rx Rexx:DOpus/ReadDir.rexx" FilePath
  106.                   end
  107.                end
  108.             end
  109.          end
  110.          else do
  111.             /* copy the file, as it is not a Dir.*/
  112.             OtherWindow
  113.             address COMMAND "rx Rexx:DOpus/CopyFile.rexx WAIT"
  114.          end
  115.       end
  116.  
  117.       /*respond to the Stop Twin Handler REXX command and shut down Twin*/
  118.       if Cmd = 'CLOSE' then do
  119.          HandlerStatus = 'CLOSE'
  120.          address command 'echo >PPipe: QUIT'
  121. /*         address command 'C:Delete T:TwinDirs/#?'  */
  122. /*         address command 'C:Delete T:TwinDirs'     */
  123.       end
  124.    end
  125. end
  126.  
  127. /* close up shop */
  128. exitit:
  129. call closeport(OurPort)
  130.  
  131. exit
  132.